package com.zte.moon.yutu;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 14-1-13
 * Time: 下午11:52
 * To change this template use File | Settings | File Templates.
 */
public class Sensor {
    private Set<Point> pits = new HashSet<Point>();

    public Sensor(String filePath) throws IOException {
        File file = new File("C:/pits.config");
        String strPits;
        String[] strArray;
        BufferedReader reader = null;

        reader = new BufferedReader(new FileReader(file));
        strPits = reader.readLine();
        strArray = strPits.split("\\|");

        for (int i = 0; i < strArray.length; i++) {
            if (strArray[i].equals(""))
                continue;
            String[] strArrayPoint = strArray[i].split(",");
            this.pits.add(new Point(Integer.parseInt(strArrayPoint[0]), Integer.parseInt(strArrayPoint[0])));
        }

    }

    public Set<Point> getPits() {
        return pits;
    }

    public boolean isPits(Point point){
        return this.pits.contains(point);
    }
}
